<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form id="form1" style="background-color: lawngreen; align="center"">
    <table border="0" cellspacing="0" align="center" >
        <tr><th align="right">名字</th><td><input type="text"  name="name"></td> </tr>
        <tr><th align="right">账号</th><td><input type="text"  name="name1"></td> </tr>
        <tr><th align="right">身份证前三位</th><td><input type="password"  name="cardId"></td> </tr>
        <tr><th align="right">密码</th><td><input type="password"  name="pwd1"></td> </tr>
        <tr><th align="right">确认密码</th><td><input type="password"  name="pwd2"></td> </tr>
        <tr><th align="right"></th><td><input type="button" name="inSub1" value="注册" onclick="queren()"></td></tr>
        <tr><th align="right"></th><td><input type="reset" name="inSub2" value="重新注册" ></td></tr>
        <tr><th align="right"></th><a href="./15.html"><td style="padding-right: 320px"><input type="button" name="inSub3" value="登录" ></td></a></tr>

    </table>
<div style="padding-right: 320px">
    <a href="./15.html"><input style="margin-bottom: 50px;" type="button" name="but4" value="登录"></a>
</div>
</form>

<script>
    console.log(document.getElementsByName("name1")[0].innerHTML)
    function queren() {
        var user1=document.getElementsByName("name1")[0].value;
        var p1=document.getElementsByName("pwd1")[0].value;
        var p2=document.getElementsByName("pwd2")[0].value;
        var cid=document.getElementsByName("cardId")[0].value;
        if (user1.length==0||user1.length>20){
            alert("请输入正确的帐号");
            return;
        }else if (p1!=p2){
            alert("密码不相同，请重新输入")
            return;
        }else if (cid.length!=3){
            alert("身份证不正确，请重新输入")
        }else {


            document.getElementById("form1").submit();
            alert("注册成功,直接登录");
            top.location='./15.html';
        }
    }

</script>



</body>
</html>